#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
typedef long long LL;

int n;
int arr[N], b[N];
LL sum = 0;
void merge(int l, int mid, int r){
    for (int i = l; i <= r; i++){
        b[i] = arr[i];
    }
    int i = l, j = mid + 1, p = l,k=0;
    while (i <= mid && j <= r){
        if (b[i] <= b[j]){
            arr[p] = b[i];
            sum+=k;
            i++;
        }
        else{
            arr[p] = b[j];
            k++;
            j++;
        }
        p++;
    }
    while(i<=mid){
        arr[p]=b[i];
        sum+=k;
        i++;
        p++;
    }
    while (j<=r){
        arr[p] = b[j];
        j++;
        p++;
    }
}
void mergesort(int l, int r){
    if (l >= r)
        return;
    int mid = (r - l) / 2 + l;
    mergesort(l, mid);
    mergesort(mid + 1,r);
    merge(l, mid, r);
}

int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    mergesort(0, n - 1);
    printf("%lld", sum);
    return 0;
}
